local baonu = fk.CreateSkill {
  name = "lingling__baonu",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable {
  ["lingling__baonu"] = "暴怒",
  [":lingling__baonu"] = "锁定技，准备阶段，你亮出牌堆顶X张牌，获得其中所有武器牌和【杀】（X为你已损失体力）。",
}

baonu:addEffect(fk.EventPhaseStart, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(baonu.name) and player.phase == Player.Start and player:getLostHp() > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local x = player:getLostHp()
    local cards = room:getNCards(x)
    room:turnOverCardsFromDrawPile(player, cards, baonu.name)
    room:delay(1000)
    cards = table.filter(cards, function(id)
      return room:getCardArea(id) == Card.Processing
    end)
    if #cards == 0 then return end
    if player.dead then
      room:cleanProcessingArea(cards)
      return
    end
    local get = table.filter(cards, function(id)
      return Fk:getCardById(id).sub_type == Card.SubtypeWeapon or Fk:getCardById(id).trueName == "slash"
    end)
    if #get > 0 and not player.dead then
      room:moveCardTo(get, Card.PlayerHand, player, fk.ReasonJustMove, baonu.name, nil, true, player)
    end
    room:cleanProcessingArea(cards)
  end,
})

return baonu
